should they be very different at all? In Listing 11-2, the p value is listed as 1.674e–05, which resolves

to 0.00001674 (to be stated as p < 0.0001). We were surprised to see a statistically significant

difference! The output says that the 95 percent confidence interval of the difference is 0.1444651

mmHg to 0.3858467 mmHg, so this small difference may be statistically significant while not being

clinically significant.

Let’s examine the output from our independent t test of mean fasting glucose values in NHANES

participants who were married compared to participants with all other marital statuses. This output is

shown in Listing 11-3.

LISTING 11-3 R Output from an Independent t Test

> t.test(NHANES$LBXGLU ~ NHANES$MARRIED)

Welch Two Sample t-test

data: NHANES$LBXGLU BY NHANES$MARRIED

t = –4.595, df = 4731.2, p-value = 4.439e–06

alternative hypothesis: true difference in means between group $

95 percent confidence interval:

–6.900665 –2.773287

sample estimates:

mean in group 0 mean in group 1

108.8034 113.6404

Importantly, at the top of Listing 11-3, notice that it says “Welch Two Sample t-test.” This is because R

insists on using Welch’s test instead of the Student t test for independent t tests because Welch’s test

accounts for unequal variance (as well as equal variance) between groups, as discussed earlier. In the

output under the alternative hypothesis, notice that it says R is testing whether the true difference in

means between group 0 and group 1 is not equal to 0 (remember, 1 = married and 0 = all other

marital statuses). R calculated a p value of 4.439e–06, which resolves to 0.000004439 — definitely

p < 0.0001! The groups are definitely statistically significantly different when it comes to average

fasting glucose.

But which group is higher? Well, for that, you can look at the last line of the output, where it says that

the mean in group 0 (all marital statuses except married) is 108.8034 mg/dL, and the mean in group 1

(married) is 113.6404 mg/dL. So does getting married raise your fasting glucose? Before you try to

answer that, please make sure you read up on confounding in Chapter 20!

But what if you just wanted to know if the variance in the fasting glucose measurement in the married

group was equal or unequal to the other group, even though you were doing a Welch test that

accommodates both? For that, you can do an F test. Because we are not sure which group’s fasting

glucose would be higher, we choose a two-sided F test and use this code: var.test(LBXGLU ~

MARRIED, NHANES, alternative = "two.sided"), which produces the output shown in Listing 11-4.

LISTING 11-4 R Output from an F Test

> var.test(LBXGLU ~ MARRIED, NHANES, alternative = "two.sided")

F test to compare two variances

data: LBXGLU by MARRIED

F = 0.97066, num df = 2410, denom df = 2332, p-value = 0.4684

alternative hypothesis: true ratio of variances is not equal to$

95 percent confidence interval:

0.8955321 1.0520382

sample estimates: